import {
    Component,
    OnInit
} from '@angular/core';
import { Router } from '@angular/router';
import { Md5 } from "ts-md5/dist/md5";
@Component({
    selector: 'register_component',
    styleUrls: ['./register.component.css'],
    templateUrl: './register.component.html'
})

export class RegisterComponent implements OnInit {
    public ngOnInit() {
    }

    user = {
        name: '',
        password: ''
    };

    msg = false;

    constructor(public router:Router) {
        this.router = router;
    }

    register() {
        let vm = this;
        if (vm.user.name && vm.user.password) {
            vm.msg = false;
            // 缓存用户信息
            localStorage.setItem('user', JSON.stringify(vm.user));
            // 路由跳转到首页,此处默认table
            vm.router.navigate(['/table']);
        } else {
            vm.msg = true;
        }
    }
}
